package com.lucas.controller;

import com.lucas.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: spring_cloud_lagou_homework
 * @author: lucasLu
 **/
@RestController
public class EmailController {

    @Autowired
    EmailService emailService;
    /**
     *发验证码到邮箱,true成功 false失败
     * @param email
     * @param code
     * @return
     */
    @RequestMapping("/{email}/{code}")
    public boolean sendEmailWithCode(@PathVariable String email , @PathVariable String code){
        String content = String.format( "<h1>欢迎使用lucas.com平台</h1>" +
                "<div>您的验证码为：<strong>%s</strong>，请尽快去验证。</div>", code);
        return emailService.sendHtmlMail(email,"注册主题",content);
    }
}
